//
//  RootViewController.m
//  EDPS
//
//  Created by 张维扬 on 15/11/23.
//  Copyright © 2015年 张维扬. All rights reserved.
//

#import "RootViewController.h"
#import "ExploreViewController.h"
#import "DestinationViewController.h"
#import "MySelfViewController.h"
#import "SearchViewController.h"
@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 创建tabBar
    [self createTabBar];
}
- (void)createTabBar
{
    // 文字
    NSMutableDictionary *tabBar_Title = [NSMutableDictionary dictionary];
    // 设置未选择文字颜色
    tabBar_Title[NSForegroundColorAttributeName] = [UIColor colorWithRed:128 / 255.0 green:128 / 255.0 blue:128 / 255.0 alpha:1];
    // 设置选择文字颜色
    NSMutableDictionary *tabBar_SelectedTitle = [NSMutableDictionary dictionary];
    tabBar_SelectedTitle[NSForegroundColorAttributeName] = [UIColor whiteColor];
    
    // 探索页面
    ExploreViewController *explore = [[ExploreViewController alloc] init];
    UINavigationController *exploreNAV = [[UINavigationController alloc] initWithRootViewController:explore];
    exploreNAV.tabBarItem.title = @"探索";
    exploreNAV.tabBarItem.image = [UIImage imageNamed:@"iconfont-explore"];
    exploreNAV.tabBarItem.selectedImage = [[UIImage imageNamed:@"iconfont-explore-click"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [exploreNAV.tabBarItem setTitleTextAttributes:tabBar_Title forState:UIControlStateNormal];
    [exploreNAV.tabBarItem setTitleTextAttributes:tabBar_SelectedTitle forState:UIControlStateSelected];
    
    // 目的地页面
    DestinationViewController *deatination = [[DestinationViewController alloc] init];
    UINavigationController *deatinationNAV = [[UINavigationController alloc] initWithRootViewController:deatination];
    deatinationNAV.tabBarItem.title = @"目的地";
    deatinationNAV.tabBarItem.image = [UIImage imageNamed:@"iconfont-destination"];
    deatinationNAV.tabBarItem.selectedImage = [[UIImage imageNamed:@"iconfont-destination-click"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [deatinationNAV.tabBarItem setTitleTextAttributes:tabBar_Title forState:UIControlStateNormal];
    [deatinationNAV.tabBarItem setTitleTextAttributes:tabBar_SelectedTitle forState:UIControlStateSelected];
    
    // 搜索页面
    SearchViewController *search = [[SearchViewController alloc] init];
    UINavigationController *searchNAV = [[UINavigationController alloc] initWithRootViewController:search];
    searchNAV.tabBarItem.title = @"搜索";
    searchNAV.tabBarItem.image = [UIImage imageNamed:@"iconfont-sousuo"];
    searchNAV.tabBarItem.selectedImage = [[UIImage imageNamed:@"iconfont-sousuo-click"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [searchNAV.tabBarItem setTitleTextAttributes:tabBar_Title forState:UIControlStateNormal];
    [searchNAV.tabBarItem setTitleTextAttributes:tabBar_SelectedTitle forState:UIControlStateSelected];
    
    // 我的
    MySelfViewController *my = [[MySelfViewController alloc] init];
    UINavigationController *myNAV = [[UINavigationController alloc] initWithRootViewController:my];
    myNAV.tabBarItem.title = @"我的";
    myNAV.tabBarItem.image = [UIImage imageNamed:@"iconfont-user"];
    myNAV.tabBarItem.selectedImage = [[UIImage imageNamed:@"iconfont-user-click"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [myNAV.tabBarItem setTitleTextAttributes:tabBar_Title forState:UIControlStateNormal];
    [myNAV.tabBarItem setTitleTextAttributes:tabBar_SelectedTitle forState:UIControlStateSelected];
    
    UITabBarController *tabBar = [[UITabBarController alloc] init];
    tabBar.viewControllers = @[exploreNAV, deatinationNAV, searchNAV, myNAV];
    
    AppDelegate *app = [UIApplication sharedApplication].delegate;
    app.window.rootViewController = tabBar;
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
